<?php


namespace App\Models;


use Illuminate\Database\Eloquent\Model;

class Shelves extends Model
{
    protected $table = 'shelves';

    protected $fillable = ['code', 'tally_id', 'warehousing_id', 'product_id', 'location_id', 'barcode', 'quantity', 'batch', 'attribute'];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * @author luffyzhao@vip.126.com
     */
    public function warehousing(){
        return $this->belongsTo(Warehousing::class);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * @author luffyzhao@vip.126.com
     */
    public function tally(){
        return $this->belongsTo(Tally::class);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * @author luffyzhao@vip.126.com
     */
    public function product(){
        return $this->belongsTo(Product::class);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * @author luffyzhao@vip.126.com
     */
    public function location(){
        return $this->belongsTo(Location::class);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function logs(){
        return $this->hasMany(ShelvesLog::class);
    }
}
